package com.test.spring.fusion.controller;

import java.util.List;

import org.spring.boot.fusion.common.params.RequestParams;
import org.spring.boot.fusion.common.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.test.spring.fusion.service.FusionUserService;
import com.test.spring.fusion.vo.UserVo;

@RestController
public class FusionUserController {
	
	@Autowired
	private FusionUserService userService;
	
	@PostMapping("findUserListByNameAndId")
	public ResponseData findUserListByNameAndId(@RequestBody RequestParams<UserVo> requestParams) {
		UserVo userVoParams = requestParams.getParams();
		List<UserVo> userVoData =userService.findUserListByNameAndId(userVoParams);
		return ResponseData.SUCCESS(userVoData);
	}
	
	@PostMapping("findUserListPage")
	public ResponseData findUserListPage(@RequestBody RequestParams<UserVo> requestParams) {
		//获取参数
		UserVo userVoParams = requestParams.getParams();
		//获取当前页
		int pageIndex = requestParams.getPageIndex();
		//获取每页显示的数据
		int pageSize = requestParams.getPageSize();
		IPage<UserVo> userVoData =userService.findUserListPage(userVoParams,pageIndex,pageSize);
		return ResponseData.SUCCESS(userVoData);
	}
}
